<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:pe="http://primefaces.org/ui/extensions">
    <h:head>
        <title>Buku Besar</title>
        <link href="./resources/css/default.css" rel="stylesheet" type="text/css" />
    </h:head>
    <h:body>
        <ui:composition>
            <h:form>
                                
                <p:toolbar>
                    <p:toolbarGroup align="left">
                        <p:commandButton value="#{bundle.btnLoad}" action="#{gledgerBean.loadData()}" update="dtGLedgers" icon="ui-icon-arrowrefresh-1-w"  /> 
                        
                        <p:commandButton type="push" action="#{rptGledgerBean.execute(gledgerBean.gledgers)}" value="#{bundle.btnPrint}"  
                                         ajax="false" image="ui-icon-print" >
<!--                            <f:setPropertyActionListener value="#{rptGledgerBean.loansimulates}" target="#{rptLoansimBean.sim}" />-->
                            <f:setPropertyActionListener value="#{gledgerBean.startDate}" target="#{rptGledgerBean.startDate}" />
                            <f:setPropertyActionListener value="#{gledgerBean.endDate}" target="#{rptGledgerBean.endDate}" />
                            <f:setPropertyActionListener value="#{gledgerBean.branchId}" target="#{rptGledgerBean.branchId}" />
                            <f:setPropertyActionListener value="#{gledgerBean.glaccnt}" target="#{rptGledgerBean.glaccnt}" />
                        </p:commandButton>
                        
                    </p:toolbarGroup>
                </p:toolbar>
                
                <h:panelGrid id="displayGLedger" cellspacing="0" cellpadding="0" border="0" rowClasses="panelGridId">
                    <p:panel header="Filter Data" style="height: 110px;">
                        
                        <h:panelGrid columns="2" border="0" cellpadding="0" cellspacing="5" columnClasses="panelGridId,panelGridId">
                            <p:outputPanel>
                                <h:panelGrid columns="3" border="0" cellpadding="0" cellspacing="3" rowClasses="panelGridId">
                                    <h:outputLabel value= "#{bundle.glaccnt}" /><h:outputLabel value= ":" />
                                    <p:selectOneMenu value="#{gledgerBean.glaccnt}" style="width: 255px;" var="g" converter="glaccnt">
                                        <f:selectItem rendered="#{gledgerBean.glaccnt!=null}" itemLabel="#{gledgerBean.glaccnt.accountName}" itemValue="#{gledgerBean.glaccnt}" />
                                        <f:selectItems value="#{gledgerBean.avblGL}" var="gl" itemLabel="#{gl.accountName}" itemValue="#{gl}"/>
                                        <p:column>#{g.accountNo}</p:column>
                                        <p:column>#{g.accountName}</p:column>
                                    </p:selectOneMenu>
                                    <h:outputLabel value= "#{bundle.branch}" /><h:outputLabel value= ":" />
                                    <p:selectOneMenu value="#{gledgerBean.branchId}" style="width: 255px;" >
                                        <f:selectItem itemValue="0" itemLabel="Semua Cabang"/>
                                        <f:selectItems value="#{gledgerBean.avblBranch}"/>
                                    </p:selectOneMenu>
                                </h:panelGrid>
                            </p:outputPanel>    
                            
                            <p:outputPanel>
                                <h:panelGrid columns="4" border="0" cellpadding="0" cellspacing="3" rowClasses="panelGridId">
                                    <h:outputLabel value= "Period" /><h:outputLabel value= ":" />
                                    <p:spinner value="#{gledgerBean.year}" min="1945" max="3000" >
                                        <p:ajax listener="#{gledgerBean.changeDate}" update="glStartDate glEndDate" />  
                                    </p:spinner>

                                    <p:selectOneMenu value="#{gledgerBean.period}" style="width: 130px;" >
                                        <f:selectItems value="#{gledgerBean.avblPeriod}"/>
                                        <p:ajax listener="#{gledgerBean.changeDate}" update="glStartDate glEndDate" process="@this"/>  
                                    </p:selectOneMenu>
                                                        
                                    <h:outputLabel value= "#{bundle.date}" /><h:outputLabel value= ":" />
                                    <p:calendar id="glStartDate" value="#{gledgerBean.startDate}" pattern="dd/MM/yyy" showOn="button"  size="18"
                                                maxdate="#{gledgerBean.maxDate}" mindate="#{gledgerBean.minDate}"/>
                                    <h:panelGrid columns="3" border="0" cellpadding="0" cellspacing="2">
                                        <h:outputLabel value= "s.d"/><p:spacer width="3" />
                                        <p:calendar id="glEndDate" value="#{gledgerBean.endDate}" pattern="dd/MM/yyy" showOn="button" size="8"
                                                maxdate="#{gledgerBean.maxDate}" mindate="#{gledgerBean.minDate}"/>
                                    </h:panelGrid>
                                </h:panelGrid>
                            </p:outputPanel>    
                        </h:panelGrid>
                    </p:panel>
                    
                    
                    <p:panel header="#{bundle.glaccnt}" >
                        <h:panelGrid columns="3" border="0" cellpadding="0" cellspacing="5">
                            
                            <p:dataTable id="dtGLedgers" value="#{gledgerBean.gledgers}" var="gl" rowIndexVar="noUrut" 
                                         scrollable="true" scrollWidth="960" resizableColumns="true">
                                
                                <p:column width="12">
                                    <f:facet name="header">No.</f:facet>
                                    <h:outputText value="#{noUrut+1}" />
                                </p:column>
                                
                                <p:column width="80" >
                                    <f:facet name="header">#{bundle.date}</f:facet>
                                    <h:outputText value="#{gl.jvDate}" />
                                </p:column>

                                <p:column width="60">
                                    <f:facet name="header">#{bundle.jvNo}</f:facet>
                                    <h:outputText value="#{gl.jvNO}" />
                                </p:column>

                                <p:column width="250" >
                                    <f:facet name="header">#{bundle.description}</f:facet>
                                    <h:outputText value="#{gl.description}" />
                                </p:column>

                                <p:column width="100" >
                                    <f:facet name="header">#{bundle.debet}</f:facet>
                                    <h:outputText value="#{gl.debet}" styleClass="numPos">
                                        <f:convertNumber groupingUsed="true" />
                                    </h:outputText>
                                </p:column>
                                
                                <p:column width="100" >
                                    <f:facet name="header">#{bundle.credit}</f:facet>
                                    <h:outputText value="#{gl.credit}" styleClass="numPos">
                                        <f:convertNumber groupingUsed="true" />
                                    </h:outputText>
                                </p:column>
                                
                                <p:column width="100" >
                                    <f:facet name="header">#{bundle.balance}</f:facet>
                                    <h:outputText value="#{gl.saldo}" styleClass="numPos">
                                        <f:convertNumber groupingUsed="true" />
                                    </h:outputText>
                                </p:column>
                                
                                
                            </p:dataTable>
                                
                        </h:panelGrid>
                    </p:panel>
                    
                </h:panelGrid>
            </h:form>
        </ui:composition>
    </h:body>
</html>